/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package koor.persistent;

import java.util.List;
import koor.entity.Teacher;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;

/**
 *
 * @author Admin
 */
public class TeacherDAO extends AbstractDAO<Teacher>{

    public TeacherDAO() {
        super();
	setClazz(Teacher.class);
    }
    
    @Override
    public List<Teacher> findByName(String string) {
        Session session = null;
        List<Teacher> entityList = null;
        try {
            session = getSession();
            entityList = (List<Teacher>) session.createCriteria(clazz)
                    .createCriteria("first_name").add(Restrictions.like("first_name", string))
                    .list();
        } catch (Exception e) {
            //
        } finally {
            if (session != null && session.isOpen()) {
                session.close();
            }
        }
        return entityList;
    }
}
